addCommandHandler("gp2",function()
	x,y,z=getElementPosition(localPlayer)
	rx,ry,rz=getElementRotation(localPlayer)
  	p=string.format("%.2f, %.2f, %.2f, %.2f, %.2f, %.2f",x,y,z,rx,ry,rz)
	setClipboard(p)
	outputChatBox(p)
end)

for k,v in ipairs ( getElementsByType ( "object" ) ) do
	if getElementData ( v, "sciana:raportow" ) then
		scianaplaczu = v
	end
	if getElementData(v,"sciana:text") then
		scianatekstu = v
	end
end

local xtext=nil
local gameView={"Logi serwerowe"}
local sx,sy=guiGetScreenSize()

function renderingInfo()
dxDrawRectangle(sx*(258)/1360, sy*(0)/768, sx*(500)/1360, sy*(23)/768, tocolor(0, 0, 0, 195), false)
	dxDrawText(xtext:gsub("#%x%x%x%x%x%x",""), sx*(258+1)/1360, sy*(0+1)/768, sx*(758+1)/1360, sy*(23+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "center", "center", false, true)
	dxDrawText(xtext:gsub("#%x%x%x%x%x%x",""), sx*(258)/1360, sy*(0)/768, sx*(758)/1360, sy*(23)/768, tocolor(255, 0, 0, 255), 1.00, "default", "center", "center", false, true)
end

function renderingInfo2()
dxDrawRectangle(sx*(258)/1360, sy*(0)/768, sx*(500)/1360, sy*(23)/768, tocolor(0, 0, 0, 195), false)
	dxDrawText(xtext:gsub("#%x%x%x%x%x%x",""), sx*(258+1)/1360, sy*(0+1)/768, sx*(758+1)/1360, sy*(23+1)/768, tocolor(0, 0, 0, 255), 1.00, "default", "center", "center", false, true)
	dxDrawText(xtext:gsub("#%x%x%x%x%x%x",""), sx*(258)/1360, sy*(0)/768, sx*(758)/1360, sy*(23)/768, tocolor(0, 192, 0, 255), 1.00, "default", "center", "center", false, true)
end

function raporcik()
	if not getElementData(localPlayer,"player:admin") then return end
	local tt={}
	reportView=getElementData(scianaplaczu,"sciana:raportow")
	for i,c in ipairs(reportView) do
	    testi = i
		if c[1] then table.insert(tt,c[1]) end
	end
	if testi > 1 then
	concat=table.concat(tt, "\n")
	exports["PSSM-gui"]:createCustomText2(concat, sx*(1028)/1360, sy*(220)/768, sx*(1344)/1360, sy*(496)/768, tocolor(255, 255, 255, 255), 1, "font19.1", "right", "top", false, false, false, false, false)
	end
end
addEventHandler("onClientRender", root, raporcik)

addEvent("admin:addText", true)
addEventHandler("admin:addText", root, function(text)
	table.insert(gameView, text)	
	if #gameView > 15 then
		table.remove(gameView, 2)
	end
end)
function raporcik2()
	if not getElementData(localPlayer,"player:ucho") then return end
	local tt={}
	reportView=getElementData(scianatekstu,"sciana:text")
	for i,c in ipairs(reportView) do
		if c[1] then table.insert(tt,c[1]) end
	end
	concat=table.concat(tt, "\n")
	exports["PSSM-gui"]:createCustomText2(concat, sx*(10)/1360, sy*(220)/768, sx*(326)/1360, sy*(497)/768, tocolor(255, 255, 255, 255), 1, "font19.1", "left", "top", false, false, false, false, false)
end
addEventHandler("onClientRender", root, raporcik2)

addEvent("admin:rendering", true)
addEventHandler("admin:rendering", root, function(text)
	xtext=text
	if isEventHandlerAdded("onClientRender",root,renderingInfo) then
		removeEventHandler ( "onClientRender", root, renderingInfo)
	end
	addEventHandler("onClientRender", root, renderingInfo)
	setTimer(function()
		removeEventHandler("onClientRender", root, renderingInfo)
	end, 8000, 1)
end)

addEvent("admin:rendering2", true)
addEventHandler("admin:rendering2", root, function(text)
	xtext=text
	if isEventHandlerAdded("onClientRender",root,renderingInfo2) then
		removeEventHandler ( "onClientRender", root, renderingInfo2)
	end
	addEventHandler("onClientRender", root, renderingInfo2)
	setTimer(function()
		removeEventHandler("onClientRender", root, renderingInfo2)
	end, 8000, 1)
end)

function greetingHandler ()
	local sound = playSound("warn.mp3") --Play wasted.mp3 from the sounds folder
	setSoundVolume(sound, 1)
	setTimer( function() stopSound(sound) end, 10*1000, 1 ) 
end
addEvent( "dzwiekwarna", true )
addEventHandler( "dzwiekwarna", localPlayer, greetingHandler )

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
	if 
		type( sEventName ) == 'string' and 
		isElement( pElementAttachedTo ) and 
		type( func ) == 'function' 
	then
		local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
		if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
			for i, v in ipairs( aAttachedFunctions ) do
				if v == func then
					return true
				end
			end
		end
	end
 
	return false
end
